<template>
    <el-form class="${objectName}EditForm" ref="${objectName}Info" :inline="true" :model="${objectName}Info" label-width="80px">
        <#list Fields as field>
            <#if field.editShow == true>
                <#if field.selectUrl??>
                    <el-form-item :label="$t('${moduleName}.${objectName}.${field.javaField!''}')">
                        <el-select v-model="${objectName}Info.${field.javaField!''}" style="width: 92%;" multiple :placeholder="$t('common.selectTips')">
                            <el-option
                                    v-for="item in options.${field.javaField!''}"
                                    :key="item.${field.selectKey!''}"
                                    :label="item.${field.selectValue!''}"
                                    :value="item.${field.selectKey!''}">
                            </el-option>
                        </el-select>
                    </el-form-item>
                <#else>
                    <el-form-item :label="$t('${moduleName}.${objectName}.${field.javaField!''}')">
                        <el-input v-model="${objectName}Info.${field.javaField!''}"></el-input>
                    </el-form-item>
                </#if>
            </#if>
        </#list>
    </el-form>
</template>
<script>
    import request from '@/utils/request'
    export default {
        name: '${objectName}Edit',
        props: ['${objectName}Info'],
        data() {
            return {
                //所有的下拉选项
                options:{
                    <#list Fields as field>
                    <#if field.selectUrl??  && field.editShow == true>
                    ${field.javaField!''}: []<#if field_has_next>,</#if>
                    </#if>
                    </#list>
                }
            }
        },
        watch: {
            ${objectName}Info: function(val) {

            }
        },
        //页面初始化加载
        created() {
            <#list Fields as field>
            <#if field.selectUrl?? && field.editShow == true>
            this.get${field.javaField?cap_first}();
            </#if>
            </#list>
        },
        methods: {
            <#list Fields as field>
            <#if field.selectUrl?? && field.editShow == true>
            get${field.javaField?cap_first}() {
                request({
                    url: '${field.selectUrl}',
                    method: 'post'
                }).then(response => {
                    this.options["${field.javaField!''}"] = response.data;
                })
            },
            </#if>
            </#list>
        }
    }
</script>
<style>
    .${objectName}EditForm .el-form-item {
        width: 45%;
    }

    .${objectName}EditForm .el-input {
        width: 100%;
    }
</style>
